library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
Eigendata<-read.table(file = "~/GitHub/vespa_analyses/Input/Eigendata.txt", header=TRUE, sep="\t")
Eigendata_shortind<-read.table(file = "~/GitHub/vespa_analyses/Input/Eigendata.txt", header=TRUE, sep="\t")

library(ggplot2)
library(ggpubr)

Outlier van nest 29, Bait 1, Individu A weggelaten in deze dataset. (600m op 2min lijkt wel heel snel) Meting in Excel script wel nog terug te vinden.

Outlier van Melle ook weggelaten (meting op 2 km niet betrouwbaar)

Volgende datasets zijn gecreëerd:

Voor het model: Flight time ~ Distance gebruiken we de dataset kortste vliegtijden per individu Omdat we hiermee de theoretische regel 1min=100m kunnen verifiëren. De imkers nemen hiervoor altijd kortste meting

Voor modellen met weerparameters, gewicht, urbanisatie: Hiervoor nemen we telkens de hele dataset, omdat elke meting van deze factoren afhangt.

1.1) ForagingSpeed vs Temperature

Graphs

Van temperatuur ook categorische variabele maken (aanraden van Prof.Vangestel)

Eigendata$Temperature_cat<-cut(Eigendata$Temperature, c(8,13,17,21,25,29,33))

Eigendata$Temperature_cat
##   [1] (21,25] (21,25] (21,25] (21,25] (21,25] (21,25] (21,25] (21,25] (21,25]
##  [10] (21,25] (17,21] (17,21] (17,21] (17,21] (17,21] (17,21] (17,21] (13,17]
##  [19] (29,33] (21,25] (21,25] (21,25] (21,25] (21,25] (29,33] (29,33] (29,33]
##  [28] <NA>    <NA>    <NA>    <NA>    <NA>    (21,25] (25,29] (25,29] (17,21]
##  [37] (17,21] (25,29] (25,29] (25,29] (25,29] (25,29] (25,29] (25,29] (29,33]
##  [46] (21,25] (21,25] (21,25] (21,25] (21,25] (13,17] (17,21] (13,17] (13,17]
##  [55] (13,17] (13,17] (13,17] (17,21] (13,17] (13,17] (13,17] (13,17] (13,17]
##  [64] (13,17] (13,17] <NA>    (17,21] (13,17] (17,21] (17,21] (17,21] (17,21]
##  [73] (17,21] (17,21] (17,21] (17,21] (17,21] (17,21] (17,21] (17,21] (17,21]
##  [82] (21,25] (21,25] (21,25] <NA>    <NA>    (21,25] (21,25] (21,25] (21,25]
##  [91] (21,25] (21,25] (21,25] <NA>    <NA>    (21,25] (21,25] (21,25] <NA>   
## [100] <NA>    <NA>    <NA>    <NA>    <NA>    (17,21] (17,21] (17,21] (13,17]
## [109] (13,17] (13,17] <NA>    <NA>    (17,21] (17,21] (17,21] (17,21] (17,21]
## [118] (17,21] <NA>    <NA>    (13,17] (13,17] <NA>    (21,25] (21,25] (17,21]
## [127] (17,21] <NA>    <NA>    (13,17] (17,21] (21,25] (21,25] (21,25] <NA>   
## [136] (8,13]  <NA>    <NA>    <NA>    (13,17] (13,17] <NA>    (13,17] (13,17]
## [145] (13,17] (13,17] <NA>    (17,21] <NA>    (13,17] (13,17] (13,17] (17,21]
## [154] (17,21] (13,17] (13,17] (13,17] (21,25] (21,25] (21,25] (13,17] (13,17]
## [163] <NA>    <NA>    <NA>    <NA>    <NA>    (17,21] (17,21] (17,21] (17,21]
## [172] <NA>    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>   
## [181] <NA>    (17,21] <NA>    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>   
## [190] (8,13]  (8,13]  (8,13]  (8,13]  (8,13]  (8,13]  (8,13]  (8,13]  (8,13] 
## [199] (8,13]  (8,13]  (8,13]  (8,13]  (8,13]  (8,13]  (8,13]  (8,13]  (13,17]
## [208] <NA>    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>    (17,21] (17,21]
## [217] <NA>    (8,13]  (8,13]  (8,13]  (13,17] (13,17] (13,17] (13,17] (13,17]
## [226] (13,17] (8,13]  (8,13]  (8,13]  (8,13]  (8,13]  (8,13]  (8,13]  (8,13] 
## [235] (8,13]  (8,13]  (13,17] (13,17] (13,17] (13,17] (13,17] (8,13]  (8,13] 
## [244] (8,13]  (8,13]  (8,13]  (8,13]  (8,13]  (8,13]  (8,13]  (8,13]  (8,13] 
## [253] <NA>    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>    <NA>   
## Levels: (8,13] (13,17] (17,21] (21,25] (25,29] (29,33]
ggplot(data=subset(Eigendata, !is.na(Temperature_cat)), aes(x=Temperature_cat)) + geom_bar(fill="lightcoral")

Model Output

  1. Temperature = continuous variable
  • Niet significant

  • Normality niet ok!

  1. Temperature = discrete variable
  • Een aantal klassen significant, interpretatie?

  • Normality niet ok!

Poisson verdeling ook geprobeerd met glmer maar foutmelding (zie email)

library(lmerTest)
## Loading required package: lme4
## Loading required package: Matrix
## 
## Attaching package: 'lmerTest'
## The following object is masked from 'package:lme4':
## 
##     lmer
## The following object is masked from 'package:stats':
## 
##     step
library(lme4)

model_temp_cont<-lmer(Flighttime_min ~ Temperature + (1|Individualcode), na.action=na.omit, data=Eigendata, offset= Distance)
summary(model_temp_cont)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Flighttime_min ~ Temperature + (1 | Individualcode)
##    Data: Eigendata
##  Offset: Distance
## 
## REML criterion at convergence: 1366.3
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.9375 -0.2898 -0.0230  0.1500  3.9428 
## 
## Random effects:
##  Groups         Name        Variance  Std.Dev.
##  Individualcode (Intercept) 67952.248 260.677 
##  Residual                       3.702   1.924 
## Number of obs: 183, groups:  Individualcode, 58
## 
## Fixed effects:
##               Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept) -332.03927   34.45121   58.47880  -9.638  1.1e-13 ***
## Temperature    0.09884    0.19540  124.22687   0.506    0.614    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr)
## Temperature -0.113
anova(model_temp_cont, ddf="Satterthwaite", type=3)
## Type III Analysis of Variance Table with Satterthwaite's method
##              Sum Sq Mean Sq NumDF  DenDF F value Pr(>F)
## Temperature 0.94747 0.94747     1 124.23  0.2559 0.6138
res<-residuals(model_temp_cont)
shapiro.test(res)
## 
##  Shapiro-Wilk normality test
## 
## data:  res
## W = 0.80863, p-value = 3.188e-14
qqnorm(res)
qqline(res)

model_temp_cat<-lmer(Flighttime_min ~ Temperature_cat + (1|Individualcode), offset=Distance, data=Eigendata)
summary(model_temp_cat)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Flighttime_min ~ Temperature_cat + (1 | Individualcode)
##    Data: Eigendata
##  Offset: Distance
## 
## REML criterion at convergence: 1329.5
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.7833 -0.2906 -0.0097  0.1433  3.7080 
## 
## Random effects:
##  Groups         Name        Variance Std.Dev.
##  Individualcode (Intercept) 68858.22 262.409 
##  Residual                       3.37   1.836 
## Number of obs: 183, groups:  Individualcode, 58
## 
## Fixed effects:
##                         Estimate Std. Error        df t value Pr(>|t|)    
## (Intercept)            -341.5757    37.1284   56.0945  -9.200 8.45e-13 ***
## Temperature_cat(13,17]    3.2036     0.8981  121.0057   3.567 0.000518 ***
## Temperature_cat(17,21]    4.7465     1.4043  121.0385   3.380 0.000976 ***
## Temperature_cat(21,25]    3.3026     2.3108  121.1265   1.429 0.155523    
## Temperature_cat(25,29]   63.4493    99.9309   56.0040   0.635 0.528058    
## Temperature_cat(29,33]    3.4708     2.7746  121.1038   1.251 0.213371    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) T_(13, T_(17, T_(21, T_(25,
## Tmp_(13,17] -0.021                            
## Tmp_(17,21] -0.026  0.639                     
## Tmp_(21,25] -0.028  0.389  0.608              
## Tmp_(25,29] -0.372  0.008  0.010  0.010       
## Tmp_(29,33] -0.025  0.324  0.506  0.833  0.009
anova(model_temp_cat, ddf="Satterthwaite", type=3)
## Type III Analysis of Variance Table with Satterthwaite's method
##                 Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
## Temperature_cat 53.121  10.624     5 97.929  3.1524 0.01109 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
res<-residuals(model_temp_cat)
shapiro.test(res)
## 
##  Shapiro-Wilk normality test
## 
## data:  res
## W = 0.84698, p-value = 1.395e-12
qqnorm(res)
qqline(res)

1.2) Flight time vs Distance + Temperature

Graph

library(knitr)
library(kableExtra)
## Warning in !is.null(rmarkdown::metadata$output) && rmarkdown::metadata$output
## %in% : 'length(x) = 2 > 1' in coercion to 'logical(1)'
## 
## Attaching package: 'kableExtra'
## The following object is masked from 'package:dplyr':
## 
##     group_rows
library("plot3D")

x <- Eigendata$Distance
y <- Eigendata$Temperature
z <- Eigendata$Flighttime_min

fit <- lm(z ~ x + y, na.action=na.exclude)
x.pred <- seq(min(x[!is.na(x)]), max(x[!is.na(x)]), length.out = 20)
y.pred <- seq(min(y[!is.na(y)]), max(y[!is.na(y)]), length.out = 20)
xy <- expand.grid( x = x.pred, y = y.pred)
z.pred <- matrix(predict(fit, newdata = xy), 
                 nrow = 20, ncol = 20)
fitpoints <- predict(fit)

scatter3D(x, y, z, pch = 19, cex = 0.6, colvar=FALSE, col="dodgerblue3", theta = 210, phi = 10, bty="u", col.panel ="grey93", expand =0.4, col.grid = "white", xlab = "Distance", ylab = "Temperature", zlab = "Flight time", surf = list(x = x.pred, y = y.pred, z = z.pred,  
facets = TRUE, col=ramp.col(col = c("dodgerblue4", "seagreen2"), n = 100, alpha=0.8), fit = fitpoints, border="black"),main = "Flight time vs Distance + Temperature")

Met plotly

Had met deze link problemen met expand.grid https://stackoverflow.com/questions/38331198/add-regression-plane-to-3d-scatter-plot-in-plotly

Dan maar grid dat van hierboven gebruikt, maar nu klopt er precies iets niet? Alle datapunten liggen boven het oppervlak.

library(plotly)
## 
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
## 
##     last_plot
## The following object is masked from 'package:stats':
## 
##     filter
## The following object is masked from 'package:graphics':
## 
##     layout
library(tidyverse)
## ── Attaching packages
## ───────────────────────────────────────
## tidyverse 1.3.2 ──
## ✔ tibble  3.1.8     ✔ purrr   1.0.1
## ✔ tidyr   1.2.1     ✔ stringr 1.5.0
## ✔ readr   2.1.4     ✔ forcats 1.0.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ tidyr::expand()          masks Matrix::expand()
## ✖ plotly::filter()         masks dplyr::filter(), stats::filter()
## ✖ kableExtra::group_rows() masks dplyr::group_rows()
## ✖ dplyr::lag()             masks stats::lag()
## ✖ tidyr::pack()            masks Matrix::pack()
## ✖ tidyr::unpack()          masks Matrix::unpack()
FlightsNoNA<-Eigendata %>%  filter(Flighttime_min!="NA")
FlightsNoNA<-FlightsNoNA %>%  filter(Temperature!="NA")
fig <- plot_ly(FlightsNoNA, x = ~Distance, y = ~Temperature, z = ~Flighttime_min, size=1)
fig <- fig %>% add_markers()
fig <- fig %>% layout(scene = list(xaxis = list(title = 'Distance'),
                     yaxis = list(title = 'Temperature'),
                     zaxis = list(title = 'Flight time (min)')))
p2 <- add_trace(p = fig,
                z = z.pred,
                x = seq(2100, 0, by = -100),
                y = seq(0, 30, by = 10),
                type = "surface")
p2

Model Ouput

  • Beide significant

  • Normality niet ok!

model_tempdist_all<-lmer(Flighttime_min ~ Distance + Temperature + (1|Individualcode), na.action=na.exclude, data=Eigendata)
summary(model_tempdist_all)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Flighttime_min ~ Distance + Temperature + (1 | Individualcode)
##    Data: Eigendata
## 
## REML criterion at convergence: 803.9
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -1.8894 -0.3936 -0.1599  0.1706  4.6284 
## 
## Random effects:
##  Groups         Name        Variance Std.Dev.
##  Individualcode (Intercept) 1.445    1.202   
##  Residual                   3.452    1.858   
## Number of obs: 183, groups:  Individualcode, 58
## 
## Fixed effects:
##              Estimate Std. Error        df t value Pr(>|t|)    
## (Intercept)  4.561776   0.845837 62.971937   5.393 1.11e-06 ***
## Distance     0.006563   0.000976 78.841216   6.725 2.52e-09 ***
## Temperature -0.147567   0.045732 80.427866  -3.227  0.00181 ** 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Distnc
## Distance     0.050       
## Temperature -0.909 -0.379
res<-residuals(model_tempdist_all)
shapiro.test(res)
## 
##  Shapiro-Wilk normality test
## 
## data:  res
## W = 0.76816, p-value = 1.014e-15
qqnorm(res)
qqline(res)

2) ForagingSpeed vs Cloudcoverage

Graphs

ggplot(Eigendata, aes(x=Cloudcoverage, y=ForagingSpeed)) + geom_point(color="lightblue") + geom_smooth(method="lm", formula =y ~ x, se=TRUE, fullrange=FALSE, level=0.95, color="darkblue") + ggtitle("All data | eigen metingen")+ theme(plot.title = element_text(hjust = 0.5, size=10))

Model Ouput

  • Niet significant

  • Normality ok!

model_cloud_all<-lmer(Flighttime_min ~ Cloudcoverage +  (1|Individualcode), offset=Distance, na.action=na.omit, data=Eigendata)
summary(model_cloud_all)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Flighttime_min ~ Cloudcoverage + (1 | Individualcode)
##    Data: Eigendata
##  Offset: Distance
## 
## REML criterion at convergence: 1055.6
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.8981 -0.3081 -0.0411  0.1862  3.6991 
## 
## Random effects:
##  Groups         Name        Variance  Std.Dev.
##  Individualcode (Intercept) 81926.936 286.229 
##  Residual                       3.905   1.976 
## Number of obs: 152, groups:  Individualcode, 39
## 
## Fixed effects:
##               Estimate Std. Error       df t value Pr(>|t|)    
## (Intercept)   -315.994     45.836   38.007  -6.894 3.42e-08 ***
## Cloudcoverage   -1.897      1.090  112.017  -1.741   0.0844 .  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr)
## Cloudcoverg -0.010
anova(model_cloud_all, ddf="Satterthwaite", type=3)
## Type III Analysis of Variance Table with Satterthwaite's method
##               Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
## Cloudcoverage  11.84   11.84     1 112.02   3.032 0.08438 .
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
res<-residuals(model_cloud_all)
shapiro.test(res)
## 
##  Shapiro-Wilk normality test
## 
## data:  res
## W = 0.8356, p-value = 9.028e-12
qqnorm(res)
qqline(res)

3.1) ForagingSpeed vs Windspeed

Graphs

Telkens voor de modellen

ForagingSpeed ~ Windspeed

ForagingSpeed ~ Windspeed²

plot1<-ggplot(Eigendata, aes(x=Windspeed, y=ForagingSpeed)) + geom_point(color="khaki3") + geom_smooth(method="lm", formula =y ~ x, se=TRUE, fullrange=FALSE, level=0.95, color="olivedrab") + ggtitle("All data | eigen metingen")+ theme(plot.title = element_text(hjust = 0.5, size=10))

plot2<-ggplot(Eigendata, aes(x=Windspeed, y=ForagingSpeed)) + geom_point(color="khaki3") + geom_smooth(method="lm", formula =y ~ I(x^2), se=TRUE, fullrange=FALSE, level=0.95, color="olivedrab") + ggtitle("All data | eigen metingen")+ theme(plot.title = element_text(hjust = 0.5, size=10))


ggarrange(plot1, plot2 + rremove("x.text"), 
          labels = c("A", "B"),
          ncol = 2, nrow = 1)

Model Output

  • Beide modellen licht significant

  • Beide normality niet ok!

model_wind_all<-lmer(Flighttime_min ~ Windspeed + (1|Individualcode), offset=Distance, na.action=na.omit, data=Eigendata)
summary(model_wind_all)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Flighttime_min ~ Windspeed + (1 | Individualcode)
##    Data: Eigendata
##  Offset: Distance
## 
## REML criterion at convergence: 1262.7
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.0307 -0.3235 -0.0332  0.1735  3.4539 
## 
## Random effects:
##  Groups         Name        Variance  Std.Dev.
##  Individualcode (Intercept) 68307.191 261.36  
##  Residual                       3.571   1.89  
## Number of obs: 174, groups:  Individualcode, 52
## 
## Fixed effects:
##              Estimate Std. Error        df t value Pr(>|t|)    
## (Intercept) -327.7082    36.2538   51.0530  -9.039 3.56e-12 ***
## Windspeed      0.9518     0.3951  121.0224   2.409   0.0175 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##           (Intr)
## Windspeed -0.023
anova(model_wind_all, ddf="Satterthwaite", type=3)
## Type III Analysis of Variance Table with Satterthwaite's method
##           Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
## Windspeed 20.731  20.731     1 121.02   5.805 0.01749 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
model_wind2_all<-lmer(Flighttime_min ~ I(Windspeed^2) + (1|Individualcode), offset=Distance, na.action=na.omit, data=Eigendata)
summary(model_wind2_all)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Flighttime_min ~ I(Windspeed^2) + (1 | Individualcode)
##    Data: Eigendata
##  Offset: Distance
## 
## REML criterion at convergence: 1264.8
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.0393 -0.3245 -0.0275  0.1740  3.4495 
## 
## Random effects:
##  Groups         Name        Variance  Std.Dev.
##  Individualcode (Intercept) 68276.457 261.298 
##  Residual                       3.551   1.884 
## Number of obs: 174, groups:  Individualcode, 52
## 
## Fixed effects:
##                  Estimate Std. Error         df t value Pr(>|t|)    
## (Intercept)    -326.99309   36.23952   51.01860  -9.023 3.79e-12 ***
## I(Windspeed^2)    0.24383    0.09524  121.02600   2.560   0.0117 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr)
## I(Wndspd^2) -0.014
anova(model_wind2_all, ddf="Satterthwaite", type=3)
## Type III Analysis of Variance Table with Satterthwaite's method
##                Sum Sq Mean Sq NumDF  DenDF F value Pr(>F)  
## I(Windspeed^2) 23.272  23.272     1 121.03   6.554 0.0117 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
res<-residuals(model_wind_all)
shapiro.test(res)
## 
##  Shapiro-Wilk normality test
## 
## data:  res
## W = 0.83203, p-value = 7.048e-13
qqnorm(res)
qqline(res)

res<-residuals(model_wind2_all)
shapiro.test(res)
## 
##  Shapiro-Wilk normality test
## 
## data:  res
## W = 0.83542, p-value = 9.856e-13
qqnorm(res)
qqline(res)

3.2) ForagingSpeed vs Windspeed | afhankelijk van de windrichting

Hiervoor werd telkens voor elke meting nagegaan of de hoornaar met meewind (tailwind), tegenwind (upwind) of loodrechte wind (perpendicular) te maken had. Dit volgens de formules:

|𝜃flight −𝜃wind| ≤ 45 is tailwind

45 < |𝜃flight −𝜃wind|<135 is (quasi) perpendicular

|𝜃 flight −𝜃wind| ≥135 upwind

Graphs

ggplot(data=subset(Eigendata, !is.na(Wind_flight)), aes(x= Wind_flight, col=Wind_flight, y=ForagingSpeed)) + geom_boxplot()
## Warning: Removed 6 rows containing non-finite values (`stat_boxplot()`).

ggplot(data=subset(Eigendata, !is.na(Wind_nest)), aes(x= Wind_nest, col=Wind_nest, y=ForagingSpeed)) + geom_boxplot()
## Warning: Removed 6 rows containing non-finite values (`stat_boxplot()`).

ggplot(data=subset(Eigendata, !is.na(Wind_flight)), aes(x= Windspeed, col=Wind_flight, y=ForagingSpeed)) + geom_point() + facet_grid(~Wind_flight) + geom_smooth(method="lm", formula = y ~ I(x^2), se=TRUE, fullrange=FALSE, level=0.95)
## Warning: Removed 6 rows containing non-finite values (`stat_smooth()`).
## Warning: Removed 6 rows containing missing values (`geom_point()`).

ggplot(data=subset(Eigendata, !is.na(Wind_nest)), aes(x= Windspeed, col=Wind_nest, y=ForagingSpeed)) + geom_point() + facet_grid(~Wind_nest) + geom_smooth(method="lm", formula = y ~ I(x^2), se=TRUE, fullrange=FALSE, level=0.95)
## Warning: Removed 6 rows containing non-finite values (`stat_smooth()`).
## Removed 6 rows containing missing values (`geom_point()`).

Model Output

Anova van Foragingspeed en de 3 windinvloeden

  • Dit voor windrichting t.o.v. richting tot het nest en t.o.v. vliegrichting

  • Niet significant

  • Normality niet oke

  • interpretatie?

windflightanova<-lmer(Flighttime_min ~ Wind_flight + (1|Individualcode), na.action=na.exclude, offset=Distance, data=Eigendata)
summary(windflightanova)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Flighttime_min ~ Wind_flight + (1 | Individualcode)
##    Data: Eigendata
##  Offset: Distance
## 
## REML criterion at convergence: 1151.3
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.8767 -0.3156 -0.0390  0.1724  3.8245 
## 
## Random effects:
##  Groups         Name        Variance  Std.Dev.
##  Individualcode (Intercept) 65409.102 255.752 
##  Residual                       3.965   1.991 
## Number of obs: 161, groups:  Individualcode, 46
## 
## Fixed effects:
##                      Estimate Std. Error        df t value Pr(>|t|)    
## (Intercept)         -319.3628    37.7103   45.0036  -8.469 7.23e-11 ***
## Wind_flighttailwind    0.1535     1.3936  113.0331   0.110    0.913    
## Wind_flightupwind     -0.8702     0.8884  113.0167  -0.980    0.329    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Wnd_flghtt
## Wnd_flghttl -0.006           
## Wnd_flghtpw -0.006  0.089
res<-residuals(windflightanova)
shapiro.test(res)
## 
##  Shapiro-Wilk normality test
## 
## data:  res
## W = 0.82875, p-value = 1.873e-12
qqnorm(res)
qqline(res)

windnestanova<-lmer(Flighttime_min ~ Wind_nest + (1|Individualcode), na.action=na.exclude, offset=Distance, data=Eigendata)
summary(windnestanova)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Flighttime_min ~ Wind_nest + (1 | Individualcode)
##    Data: Eigendata
##  Offset: Distance
## 
## REML criterion at convergence: 1149.6
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.8920 -0.3231 -0.0462  0.1811  3.8447 
## 
## Random effects:
##  Groups         Name        Variance  Std.Dev.
##  Individualcode (Intercept) 65436.126 255.805 
##  Residual                       3.923   1.981 
## Number of obs: 161, groups:  Individualcode, 46
## 
## Fixed effects:
##                    Estimate Std. Error        df t value Pr(>|t|)    
## (Intercept)       -319.1543    37.7196   45.0110  -8.461 7.41e-11 ***
## Wind_nesttailwind    0.4132     1.4495  113.0518   0.285    0.776    
## Wind_nestupwind     -1.6444     1.1318  113.0384  -1.453    0.149    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Wnd_nstt
## Wnd_nsttlwn -0.008         
## Wnd_nstpwnd -0.008  0.000
res<-residuals(windnestanova)
shapiro.test(res)
## 
##  Shapiro-Wilk normality test
## 
## data:  res
## W = 0.83112, p-value = 2.345e-12
qqnorm(res)
qqline(res)

ForagingSpeed vs WindSpeed voor Tailwind dataset

  • Significant

  • Normality niet ok!

data_tailwind<-subset(Eigendata, Wind_flight == "tailwind")

model_tailwind<-lmer(Flighttime_min ~ Windspeed + (1|Individualcode), offset= Distance, na.action=na.omit, data=data_tailwind)
summary(model_tailwind)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Flighttime_min ~ Windspeed + (1 | Individualcode)
##    Data: data_tailwind
##  Offset: Distance
## 
## REML criterion at convergence: 158.2
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -1.74181 -0.18655 -0.03152  0.01763  1.88834 
## 
## Random effects:
##  Groups         Name        Variance Std.Dev.
##  Individualcode (Intercept) 46780.21 216.287 
##  Residual                      10.78   3.283 
## Number of obs: 21, groups:  Individualcode, 8
## 
## Fixed effects:
##              Estimate Std. Error        df t value Pr(>|t|)   
## (Intercept) -1109.162    240.549     5.999  -4.611  0.00365 **
## Windspeed     314.022    104.860     5.999   2.995  0.02418 * 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##           (Intr)
## Windspeed -0.948
anova(model_tailwind, ddf="Satterthwaite", type=3)
## Type III Analysis of Variance Table with Satterthwaite's method
##           Sum Sq Mean Sq NumDF  DenDF F value  Pr(>F)  
## Windspeed 96.645  96.645     1 5.9991   8.968 0.02418 *
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
res<-residuals(model_tailwind)
shapiro.test(res)
## 
##  Shapiro-Wilk normality test
## 
## data:  res
## W = 0.82908, p-value = 0.001892
qqnorm(res)
qqline(res)

ForagingSpeed vs WindSpeed voor Perpendicular dataset

  • Significant

  • Normality niet ok!

data_perpendicular<-subset(Eigendata, Wind_flight == "perpendicular")

model_perpendicular<-lmer(Flighttime_min ~ Windspeed + (1|Individualcode), offset= Distance, na.action=na.omit, data=data_perpendicular)
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## unable to evaluate scaled gradient
## Warning in checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
## Model failed to converge: degenerate Hessian with 1 negative eigenvalues
summary(model_perpendicular)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Flighttime_min ~ Windspeed + (1 | Individualcode)
##    Data: data_perpendicular
##  Offset: Distance
## 
## REML criterion at convergence: 730.6
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.0291 -0.3957 -0.0109  0.2275  3.5200 
## 
## Random effects:
##  Groups         Name        Variance  Std.Dev.
##  Individualcode (Intercept) 55413.701 235.401 
##  Residual                       2.319   1.523 
## Number of obs: 104, groups:  Individualcode, 33
## 
## Fixed effects:
##              Estimate Std. Error        df t value Pr(>|t|)    
## (Intercept) -307.2799    40.9876   32.0278  -7.497 1.55e-08 ***
## Windspeed      1.9726     0.4035   70.0147   4.888 6.23e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##           (Intr)
## Windspeed -0.021
## optimizer (nloptwrap) convergence code: 0 (OK)
## unable to evaluate scaled gradient
## Model failed to converge: degenerate  Hessian with 1 negative eigenvalues
res<-residuals(model_perpendicular)
shapiro.test(res)
## 
##  Shapiro-Wilk normality test
## 
## data:  res
## W = 0.88169, p-value = 1.377e-07
qqnorm(res)
qqline(res)

ForagingSpeed vs WindSpeed voor Upwind dataset

  • Niet significant

  • Normality niet ok!

data_upwind<-subset(Eigendata, Wind_flight == "upwind")

model_upwind<-lmer(Flighttime_min ~ Windspeed + (1|Individualcode), offset=Distance, na.action=na.omit, data=data_upwind)
summary(model_upwind)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Flighttime_min ~ Windspeed + (1 | Individualcode)
##    Data: data_upwind
##  Offset: Distance
## 
## REML criterion at convergence: 248.3
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -1.65651 -0.32560 -0.01373  0.16570  2.43454 
## 
## Random effects:
##  Groups         Name        Variance  Std.Dev.
##  Individualcode (Intercept) 38919.718 197.281 
##  Residual                       2.771   1.665 
## Number of obs: 36, groups:  Individualcode, 12
## 
## Fixed effects:
##             Estimate Std. Error       df t value Pr(>|t|)   
## (Intercept) -201.008     57.112   11.125  -3.520  0.00472 **
## Windspeed     -1.029      2.015   23.052  -0.511  0.61442   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##           (Intr)
## Windspeed -0.075
res<-residuals(model_upwind)
shapiro.test(res)
## 
##  Shapiro-Wilk normality test
## 
## data:  res
## W = 0.8614, p-value = 0.0003521
qqnorm(res)
qqline(res)

4) ForagingSpeed vs Weight individual

Graphs

ggplot(Eigendata, aes(x=Weight_ind, y=ForagingSpeed)) + geom_point(color="plum") + geom_smooth(method="lm", formula =y ~ x, se=TRUE, fullrange=FALSE, level=0.95, color="darkorchid4") + ggtitle("All data")+ theme(plot.title = element_text(hjust = 0.5, size=10))

Model Output

  • Niet significant

  • Normality ok!

model_weight_all<-lmer(Flighttime_min ~ Weight_ind + (1|Individualcode), offset=Distance, na.action=na.omit, data=Eigendata)
summary(model_weight_all)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Flighttime_min ~ Weight_ind + (1 | Individualcode)
##    Data: Eigendata
##  Offset: Distance
## 
## REML criterion at convergence: 557.1
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.2045 -0.3196 -0.0862  0.1576  3.4639 
## 
## Random effects:
##  Groups         Name        Variance  Std.Dev.
##  Individualcode (Intercept) 79697.832 282.308 
##  Residual                       3.194   1.787 
## Number of obs: 89, groups:  Individualcode, 20
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)
## (Intercept)  -301.93     341.39   18.00  -0.884    0.388
## Weight_ind     39.82    1000.02   18.00   0.040    0.969
## 
## Correlation of Fixed Effects:
##            (Intr)
## Weight_ind -0.983
anova(model_weight_all, ddf="Satterthwaite", type=3)
## Type III Analysis of Variance Table with Satterthwaite's method
##               Sum Sq   Mean Sq NumDF  DenDF F value Pr(>F)
## Weight_ind 0.0050637 0.0050637     1 17.999  0.0016 0.9687
res<-residuals(model_weight_all)
shapiro.test(res)
## 
##  Shapiro-Wilk normality test
## 
## data:  res
## W = 0.77318, p-value = 2.123e-10
qqnorm(res)
qqline(res)

5.1) ForagingSpeed vs Urbanisation (Traject 100m)

Graphs

Urbanisatiecirkels niet berekend, meteen trajecten genomen want die zijn betere maatstaf

Verder werken met 100m buffer!

# Meting in urbaan gebied met koude temperatuur weglaten (Nest 38 en 39, 3 wiekpotten)

Eigendata2<-Eigendata %>%  filter(Traject100m!=0.504960)
Eigendata2<-Eigendata2 %>%  filter(Traject100m!=0.496950)
Eigendata2<-Eigendata2 %>%  filter(Traject100m!=0.411898)

Eigendata_shortind2<-Eigendata_shortind %>%  filter(Traject100m!=0.504960)
Eigendata_shortind2<-Eigendata_shortind2 %>%  filter(Traject100m!=0.496950)
Eigendata_shortind2<-Eigendata_shortind2 %>%  filter(Traject100m!=0.411898)


plot1<-ggplot(data=subset(Eigendata, !is.na(Observer)), aes(x=Traject100m, y=ForagingSpeed)) + geom_point(col="slateblue1") + geom_abline(intercept=3.8984, slope= -5.3143, color="slateblue4", linewidth=1) + ggtitle("Met outlier | random effects") + xlim(0, 0.6)
               
plot2<-ggplot(data=subset(Eigendata, !is.na(Observer)), aes(x=Traject100m, y=ForagingSpeed)) + geom_point(col="slateblue1") + geom_smooth(method="lm", formula =y ~ x, se=TRUE, fullrange=FALSE, level=0.95, color="slateblue4") + ggtitle("Met outlier | zonder random effects") + xlim(0, 0.6)

plot3<-ggplot(data=subset(Eigendata2, !is.na(Observer)), aes(x=Traject100m, y=ForagingSpeed)) + geom_point(col="slateblue1") + geom_abline(intercept=3.7838, slope= -4.0061, color="slateblue4", linewidth=1) + ggtitle("Zonder outlier | random effects") + xlim(0, 0.6)

plot4<-ggplot(data=subset(Eigendata2, !is.na(Observer)), aes(x=Traject100m, y=ForagingSpeed)) + geom_point(col="slateblue1") + geom_smooth(method="lm", formula =y ~ x, se=TRUE, fullrange=FALSE, level=0.95, color="slateblue4") + ggtitle("Zonder outlier | zonder random effects") + xlim(0, 0.6)
               

ggarrange(plot1, plot2, plot3, plot4 + rremove("x.text"), 
          labels = c("A", "B", "C", "D"),
          ncol = 2, nrow = 2)
## Warning: Removed 26 rows containing missing values (`geom_point()`).
## Warning: Removed 26 rows containing non-finite values (`stat_smooth()`).
## Warning: Removed 26 rows containing missing values (`geom_point()`).
## Removed 26 rows containing missing values (`geom_point()`).
## Warning: Removed 26 rows containing non-finite values (`stat_smooth()`).
## Warning: Removed 26 rows containing missing values (`geom_point()`).

Verder werken met 100m buffer!

Graph Temperature vs Urbanisation

ggplot(data=subset(Eigendata, !is.na(Temperature_cat)), aes(x=Temperature_cat, col=Temperature_cat, y=Traject100m)) + geom_boxplot()

Model Output

Met outlier

  • Hoogsignificant

  • Normality niet ok!

model_urb1<-lmer(Flighttime_min ~ Traject100m + (1|Individualcode), offset=Distance, na.action=na.omit, data=Eigendata)
summary(model_urb1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Flighttime_min ~ Traject100m + (1 | Individualcode)
##    Data: Eigendata
##  Offset: Distance
## 
## REML criterion at convergence: 1918
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.0862 -0.2381 -0.0067  0.1117  4.1024 
## 
## Random effects:
##  Groups         Name        Variance  Std.Dev.
##  Individualcode (Intercept) 69478.334 263.587 
##  Residual                       3.445   1.856 
## Number of obs: 234, groups:  Individualcode, 94
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)  -551.80      42.05   92.00 -13.124  < 2e-16 ***
## Traject100m  1018.13     225.44   92.00   4.516 1.86e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr)
## Traject100m -0.763
anova(model_urb1, ddf="Satterthwaite", type=3)
## Type III Analysis of Variance Table with Satterthwaite's method
##             Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)    
## Traject100m 70.262  70.262     1 91.998  20.397 1.863e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
res<-residuals(model_urb1)
shapiro.test(res)
## 
##  Shapiro-Wilk normality test
## 
## data:  res
## W = 0.77701, p-value < 2.2e-16
qqnorm(res)
qqline(res)

Zonder outlier

  • Significant

  • Normality niet ok!

model_urb2<-lmer(Flighttime_min ~ Traject100m + (1|Individualcode), offset=Distance, na.action=na.omit, data=Eigendata2)
summary(model_urb2)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Flighttime_min ~ Traject100m + (1 | Individualcode)
##    Data: Eigendata2
##  Offset: Distance
## 
## REML criterion at convergence: 1679.8
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.7342 -0.2214 -0.0047  0.0920  4.0368 
## 
## Random effects:
##  Groups         Name        Variance  Std.Dev.
##  Individualcode (Intercept) 73469.487 271.053 
##  Residual                       2.352   1.534 
## Number of obs: 199, groups:  Individualcode, 89
## 
## Fixed effects:
##             Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)  -550.98      46.42   87.00 -11.870  < 2e-16 ***
## Traject100m  1009.41     291.35   87.00   3.465 0.000827 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr)
## Traject100m -0.785
anova(model_urb2, ddf="Satterthwaite", type=3)
## Type III Analysis of Variance Table with Satterthwaite's method
##             Sum Sq Mean Sq NumDF  DenDF F value    Pr(>F)    
## Traject100m 28.229  28.229     1 86.999  12.004 0.0008265 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
res<-residuals(model_urb2)
shapiro.test(res)
## 
##  Shapiro-Wilk normality test
## 
## data:  res
## W = 0.71442, p-value < 2.2e-16
qqnorm(res)
qqline(res)

5.2) ForagingSpeed vs Urbanisation (Categorisch)

ggplot(data=Eigendata, aes(x=Urbanisation, y=ForagingSpeed, col=Urbanisation)) + geom_boxplot() 
## Warning: Removed 26 rows containing non-finite values (`stat_boxplot()`).

model_urb_cat<-lmer(Flighttime_min ~ Urbanisation + (1|Individualcode), offset=Distance, na.action=na.omit, data=Eigendata )
summary(model_urb_cat)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: Flighttime_min ~ Urbanisation + (1 | Individualcode)
##    Data: Eigendata
##  Offset: Distance
## 
## REML criterion at convergence: 1906.2
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.0847 -0.2381 -0.0062  0.1113  4.1025 
## 
## Random effects:
##  Groups         Name        Variance  Std.Dev.
##  Individualcode (Intercept) 67030.070 258.902 
##  Residual                       3.445   1.856 
## Number of obs: 234, groups:  Individualcode, 94
## 
## Fixed effects:
##                           Estimate Std. Error      df t value Pr(>|t|)    
## (Intercept)                -524.37      40.94   91.00 -12.809  < 2e-16 ***
## UrbanisationRandstedelijk   106.72      61.41   91.00   1.738   0.0856 .  
## UrbanisationVerstedelijkt   346.48      68.72   91.00   5.042 2.34e-06 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) UrbnsR
## UrbnstnRnds -0.667       
## UrbnstnVrst -0.596  0.397

6) Flight error vs urbanisation (25m, 50m, 100m)

Flight error is the difference between the actual angle from the bait to the nest and the flight direction I measured.

Graphs

plot28<-ggplot(data=subset(Eigendata, !is.na(Observer)), aes(x=Traject25m, y=FlightError)) + geom_point(col="hotpink1") + geom_smooth(method="lm", formula =y ~ x, se=TRUE, fullrange=FALSE, level=0.95, color="violetred4")

plot29<-ggplot(data=subset(Eigendata, !is.na(Observer)), aes(x=Traject50m, y=FlightError)) + geom_point(col="hotpink1") + geom_smooth(method="lm", formula =y ~ x , se=TRUE, fullrange=FALSE, level=0.95, color="violetred4")

plot30<-ggplot(data=subset(Eigendata, !is.na(Observer)), aes(x=Traject100m, y=FlightError)) + geom_point(col="hotpink1")+ geom_smooth(method="lm", formula =y ~ x, se=TRUE, fullrange=FALSE, level=0.95, color="violetred4")

ggarrange(plot28, plot29, plot30 + rremove("x.text"), 
          labels = c("A", "B", "C"),
          ncol = 2, nrow = 2)
## Warning: Removed 9 rows containing non-finite values (`stat_smooth()`).
## Warning: Removed 9 rows containing missing values (`geom_point()`).
## Warning: Removed 9 rows containing non-finite values (`stat_smooth()`).
## Warning: Removed 9 rows containing missing values (`geom_point()`).
## Warning: Removed 9 rows containing non-finite values (`stat_smooth()`).
## Warning: Removed 9 rows containing missing values (`geom_point()`).

Model Output

  • Allemaal niet significant

  • Allemaal normality niet ok!

model_errurb25<-lmer(FlightError ~ Traject25m + (1|NestID) + (1|NestID:BaitID) + (1|Individualcode), na.action=na.omit, data=Eigendata)
summary(model_errurb25)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: FlightError ~ Traject25m + (1 | NestID) + (1 | NestID:BaitID) +  
##     (1 | Individualcode)
##    Data: Eigendata
## 
## REML criterion at convergence: 1947.1
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.7734 -0.1939 -0.0500  0.0181  6.9743 
## 
## Random effects:
##  Groups         Name        Variance Std.Dev.
##  Individualcode (Intercept) 133.89   11.571  
##  NestID:BaitID  (Intercept) 119.73   10.942  
##  NestID         (Intercept)  14.35    3.788  
##  Residual                    55.40    7.443  
## Number of obs: 251, groups:  Individualcode, 111; NestID:BaitID, 85; NestID, 34
## 
## Fixed effects:
##             Estimate Std. Error     df t value Pr(>|t|)    
## (Intercept)   17.796      2.744 39.401   6.484 1.05e-07 ***
## Traject25m    -3.487     14.699 48.243  -0.237    0.813    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##            (Intr)
## Traject25m -0.704
anova(model_errurb25, ddf="Satterthwaite", type=3)
## Type III Analysis of Variance Table with Satterthwaite's method
##            Sum Sq Mean Sq NumDF  DenDF F value Pr(>F)
## Traject25m  3.119   3.119     1 48.243  0.0563 0.8135
model_errurb50<-lmer(FlightError ~ Traject50m + (1|NestID) + (1|NestID:BaitID) + (1|Individualcode), na.action=na.omit, data=Eigendata)
summary(model_errurb50)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: FlightError ~ Traject50m + (1 | NestID) + (1 | NestID:BaitID) +  
##     (1 | Individualcode)
##    Data: Eigendata
## 
## REML criterion at convergence: 1946.9
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.7832 -0.1962 -0.0514  0.0206  6.9719 
## 
## Random effects:
##  Groups         Name        Variance Std.Dev.
##  Individualcode (Intercept) 134.66   11.604  
##  NestID:BaitID  (Intercept) 120.80   10.991  
##  NestID         (Intercept)  12.35    3.514  
##  Residual                    55.33    7.438  
## Number of obs: 251, groups:  Individualcode, 111; NestID:BaitID, 85; NestID, 34
## 
## Fixed effects:
##             Estimate Std. Error     df t value Pr(>|t|)    
## (Intercept)   16.620      2.846 40.187   5.841  7.8e-07 ***
## Traject50m     5.634     15.381 43.317   0.366    0.716    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##            (Intr)
## Traject50m -0.734
anova(model_errurb50, ddf="Satterthwaite", type=3)
## Type III Analysis of Variance Table with Satterthwaite's method
##            Sum Sq Mean Sq NumDF  DenDF F value Pr(>F)
## Traject50m 7.4251  7.4251     1 43.317  0.1342 0.7159
model_errurb100<-lmer(FlightError ~ Traject100m + (1|NestID) + (1|NestID:BaitID) + (1|Individualcode), na.action=na.omit, data=Eigendata)
summary(model_errurb100)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: FlightError ~ Traject100m + (1 | NestID) + (1 | NestID:BaitID) +  
##     (1 | Individualcode)
##    Data: Eigendata
## 
## REML criterion at convergence: 1946.8
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.7833 -0.1966 -0.0513  0.0225  6.9715 
## 
## Random effects:
##  Groups         Name        Variance Std.Dev.
##  Individualcode (Intercept) 134.40   11.593  
##  NestID:BaitID  (Intercept) 121.48   11.022  
##  NestID         (Intercept)  11.92    3.452  
##  Residual                    55.33    7.439  
## Number of obs: 251, groups:  Individualcode, 111; NestID:BaitID, 85; NestID, 34
## 
## Fixed effects:
##             Estimate Std. Error     df t value Pr(>|t|)    
## (Intercept)   16.575      2.962 40.888   5.597 1.63e-06 ***
## Traject100m    5.851     16.003 41.504   0.366    0.717    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr)
## Traject100m -0.759
anova(model_errurb100, ddf="Satterthwaite", type=3)
## Type III Analysis of Variance Table with Satterthwaite's method
##             Sum Sq Mean Sq NumDF  DenDF F value Pr(>F)
## Traject100m 7.3957  7.3957     1 41.504  0.1337 0.7165
res<-residuals(model_errurb25)
shapiro.test(res)
## 
##  Shapiro-Wilk normality test
## 
## data:  res
## W = 0.58149, p-value < 2.2e-16
qqnorm(res)
qqline(res)

res<-residuals(model_errurb50)
shapiro.test(res)
## 
##  Shapiro-Wilk normality test
## 
## data:  res
## W = 0.58086, p-value < 2.2e-16
qqnorm(res)
qqline(res)

res<-residuals(model_errurb100)
shapiro.test(res)
## 
##  Shapiro-Wilk normality test
## 
## data:  res
## W = 0.581, p-value < 2.2e-16
qqnorm(res)
qqline(res)

Model Selection

fullmodel<-lmer(ForagingSpeed ~ Traject100m + Windspeed + Temperature + Cloudcoverage + Weight_ind + (1|NestID) + (1|NestID:BaitID) + (1|Individualcode), na.action=na.omit, data=Eigendata)
## boundary (singular) fit: see help('isSingular')
summary(fullmodel)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: 
## ForagingSpeed ~ Traject100m + Windspeed + Temperature + Cloudcoverage +  
##     Weight_ind + (1 | NestID) + (1 | NestID:BaitID) + (1 | Individualcode)
##    Data: Eigendata
## 
## REML criterion at convergence: 170
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.7356 -0.5550  0.1066  0.5685  1.8733 
## 
## Random effects:
##  Groups         Name        Variance Std.Dev.
##  Individualcode (Intercept) 0.03398  0.1843  
##  NestID:BaitID  (Intercept) 0.31924  0.5650  
##  NestID         (Intercept) 0.00000  0.0000  
##  Residual                   0.30817  0.5551  
## Number of obs: 88, groups:  Individualcode, 20; NestID:BaitID, 15; NestID, 10
## 
## Fixed effects:
##               Estimate Std. Error       df t value Pr(>|t|)   
## (Intercept)    4.99457    2.20523 29.00627   2.265  0.03117 * 
## Traject100m   -7.86760    2.58297 18.69255  -3.046  0.00674 **
## Windspeed     -0.17727    0.16151  9.98177  -1.098  0.29815   
## Temperature   -0.03233    0.08430 27.81931  -0.384  0.70425   
## Cloudcoverage  1.31882    0.39406 24.27275   3.347  0.00266 **
## Weight_ind    -1.44193    2.55293 10.61380  -0.565  0.58394   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Trj100 Wndspd Tmprtr Cldcvr
## Traject100m -0.789                            
## Windspeed    0.204 -0.409                     
## Temperature -0.888  0.775 -0.384              
## Cloudcoverg  0.241 -0.388  0.127 -0.327       
## Weight_ind  -0.545  0.188  0.084  0.150 -0.048
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
model1<-lmer(ForagingSpeed ~ Traject100m + Windspeed + Cloudcoverage + Weight_ind + (1|NestID) + (1|NestID:BaitID) + (1|Individualcode), na.action=na.omit, data=Eigendata)
## boundary (singular) fit: see help('isSingular')
summary(model1)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: 
## ForagingSpeed ~ Traject100m + Windspeed + Cloudcoverage + Weight_ind +  
##     (1 | NestID) + (1 | NestID:BaitID) + (1 | Individualcode)
##    Data: Eigendata
## 
## REML criterion at convergence: 167
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.6747 -0.5380  0.1197  0.5758  1.9362 
## 
## Random effects:
##  Groups         Name        Variance Std.Dev.
##  Individualcode (Intercept) 0.03317  0.1821  
##  NestID:BaitID  (Intercept) 0.28865  0.5373  
##  NestID         (Intercept) 0.00000  0.0000  
##  Residual                   0.30791  0.5549  
## Number of obs: 88, groups:  Individualcode, 20; NestID:BaitID, 15; NestID, 10
## 
## Fixed effects:
##               Estimate Std. Error      df t value Pr(>|t|)   
## (Intercept)     4.2462     0.9816 10.7873   4.326  0.00126 **
## Traject100m    -7.0951     1.5703  8.0472  -4.518  0.00193 **
## Windspeed      -0.1992     0.1439  9.4887  -1.384  0.19790   
## Cloudcoverage   1.2675     0.3639 22.4685   3.483  0.00206 **
## Weight_ind     -1.3126     2.4408 10.0199  -0.538  0.60249   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Trj100 Wndspd Cldcvr
## Traject100m -0.343                     
## Windspeed   -0.325 -0.195              
## Cloudcoverg -0.121 -0.231  0.017       
## Weight_ind  -0.906  0.115  0.155  0.007
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
model2<-lmer(ForagingSpeed ~ Traject100m + Windspeed + Cloudcoverage + (1|NestID) + (1|NestID:BaitID) + (1|Individualcode), na.action=na.omit, data=Eigendata)
summary(model2)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: ForagingSpeed ~ Traject100m + Windspeed + Cloudcoverage + (1 |  
##     NestID) + (1 | NestID:BaitID) + (1 | Individualcode)
##    Data: Eigendata
## 
## REML criterion at convergence: 343.7
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -2.46705 -0.53111  0.00685  0.48244  2.85559 
## 
## Random effects:
##  Groups         Name        Variance Std.Dev.
##  Individualcode (Intercept) 0.09978  0.3159  
##  NestID:BaitID  (Intercept) 0.39334  0.6272  
##  NestID         (Intercept) 0.25303  0.5030  
##  Residual                   0.37363  0.6113  
## Number of obs: 152, groups:  Individualcode, 39; NestID:BaitID, 26; NestID, 15
## 
## Fixed effects:
##                Estimate Std. Error        df t value Pr(>|t|)    
## (Intercept)     4.99137    0.43247  22.10904  11.542 7.87e-11 ***
## Traject100m    -8.09188    1.46500  13.92745  -5.523 7.64e-05 ***
## Windspeed      -0.29289    0.09917  81.93301  -2.953   0.0041 ** 
## Cloudcoverage   0.32661    0.27303 124.69507   1.196   0.2339    
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Trj100 Wndspd
## Traject100m -0.661              
## Windspeed   -0.454 -0.049       
## Cloudcoverg -0.180 -0.230  0.106
model3<-lmer(ForagingSpeed ~ Traject100m + Windspeed + (1|NestID) + (1|NestID:BaitID) + (1|Individualcode), na.action=na.omit, data=Eigendata)
summary(model3)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: ForagingSpeed ~ Traject100m + Windspeed + (1 | NestID) + (1 |  
##     NestID:BaitID) + (1 | Individualcode)
##    Data: Eigendata
## 
## REML criterion at convergence: 412.1
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -2.53652 -0.49591  0.01821  0.49551  2.83727 
## 
## Random effects:
##  Groups         Name        Variance Std.Dev.
##  Individualcode (Intercept) 0.08236  0.2870  
##  NestID:BaitID  (Intercept) 0.93614  0.9675  
##  NestID         (Intercept) 0.02917  0.1708  
##  Residual                   0.37294  0.6107  
## Number of obs: 174, groups:  Individualcode, 52; NestID:BaitID, 37; NestID, 20
## 
## Fixed effects:
##              Estimate Std. Error        df t value Pr(>|t|)    
## (Intercept)   4.87080    0.36651  30.78189  13.290 2.72e-14 ***
## Traject100m  -7.39979    1.32907  19.45673  -5.568 2.09e-05 ***
## Windspeed    -0.20583    0.09498 138.14425  -2.167    0.032 *  
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Correlation of Fixed Effects:
##             (Intr) Trj100
## Traject100m -0.655       
## Windspeed   -0.551 -0.018
res<-residuals(model3)
shapiro.test(res)
## 
##  Shapiro-Wilk normality test
## 
## data:  res
## W = 0.98787, p-value = 0.1401
qqnorm(res)
qqline(res)

library(cAIC4)
## Loading required package: stats4
## Loading required package: nlme
## 
## Attaching package: 'nlme'
## The following object is masked from 'package:lme4':
## 
##     lmList
## The following object is masked from 'package:dplyr':
## 
##     collapse
library(MASS)
## 
## Attaching package: 'MASS'
## The following object is masked from 'package:plotly':
## 
##     select
## The following object is masked from 'package:dplyr':
## 
##     select
library(AICcmodavg)
## 
## Attaching package: 'AICcmodavg'
## The following object is masked from 'package:lme4':
## 
##     checkConv
AIC(fullmodel)
## [1] 190.0063
AIC(model1)
## [1] 185.0204
AIC(model2)
## [1] 359.7193
AIC(model3)
## [1] 426.0821

Multicollinearity check

library(ggcorrplot)
library(car)
## Loading required package: carData
## 
## Attaching package: 'car'
## The following object is masked from 'package:purrr':
## 
##     some
## The following object is masked from 'package:dplyr':
## 
##     recode
datacor<-Eigendata[, c("Temperature", "Cloudcoverage", "Windspeed", "Weight_ind", "Traject100m", "NestID")]
source("~/GitHub/vespa_analyses/Input/HighstatLibV10.R") 
corvif(datacor)
## 
## 
## Variance inflation factors
## 
##                   GVIF
## Temperature   6.692872
## Cloudcoverage 1.356257
## Windspeed     1.332447
## Weight_ind    1.530327
## Traject100m   6.778816
## NestID        2.226214
cormat <- round(cor(datacor, use = "pairwise.complete.obs"), 2)
ggcorrplot(cormat, lab= TRUE, type = "lower", ggtheme = ggplot2::theme_gray,
   colors = c("#6D9EC1", "white", "#E46726"))

plot(Temperature~Traject100m, xlab="Urbanisation", data=Eigendata)

Eerder toeval dat Temperature en Traject100m gecorreleeerd zijn?

Eigendata$NestID<-as.factor(Eigendata$NestID)
ggplot(Eigendata, aes(x=NestID, col=NestID, y=Temperature)) + geom_boxplot()
## Warning: Removed 68 rows containing non-finite values (`stat_boxplot()`).